package com.ht.servlet;

import com.ht.enums.ErrorCode;
import com.ht.util.ResponseUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置编码
        req.setCharacterEncoding("utf-8");
        //获取用户名和密码
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        //校验参数
        if(username == null || username.trim().length() == 0){
            //用户名不能为空
            ResponseUtil.fail(resp, ErrorCode.PARAM_ERROR);
            return;
        }
    if(password ==null || password.trim().length() == 0){
        //密码不能为空
        ResponseUtil.fail(resp, ErrorCode.PARAM_ERROR);
        return;
    }
    }
}
